import 'package:drift/drift.dart';
import 'package:drift/native.dart';

part 'database.g.dart'; //执行 dart run build_runner build 会生成对应的操作当前表数据库代码

class TodoItems extends Table {
  IntColumn get id => integer().autoIncrement()();
  TextColumn get title => text().withLength(min: 6, max: 32)();
  TextColumn get content => text().named('body')();
  DateTimeColumn get createdAt => dateTime().nullable()();
}

// @DriftDatabase(tables: [TodoItems])
@DriftDatabase(

  include: {'student.drift'},
)

class AppDatabase extends _$AppDatabase {
  // This example creates a simple in-memory database (without actual
  // persistence).
  // To store data, see the database setups from other "Getting started" guides.
  AppDatabase() : super(NativeDatabase.memory());

  @override
  int get schemaVersion => 1;
}


//
// class AppDatabase extends _$AppDatabase {
//   AppDatabase([QueryExecutor? executor]) : super(executor ?? _openConnection());
//
//   @override
//   int get schemaVersion => 1;
//
//   static QueryExecutor _openConnection() {
//     return driftDatabase(
//       name: 'mydatabase',
//       native: const DriftNativeOptions(
//         // By default, `driftDatabase` from `package:drift_flutter` stores the
//         // database files in `getApplicationDocumentsDirectory()`.
//         databaseDirectory: Uri.parse('C:/Users/admin/Desktop/mydatabase.db'),
//       ),
//       // If you need web support, see https://drift.simonbinder.eu/platforms/web/
//     );
//   }
// }
